<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Location extends CI_Controller {

    public function Location() {
        parent::__construct();
        //$this -> load -> model('admin_model');
        $this->load->model('location_model');
    }

    public function get_province() {
        $data['data_cate'] = 'province';
        $data['locations'] = $this->location_model->get_province();
        $data['content'] = 'ajax_response/response_location';
        $data['display'] = "ខេត្ត";
        $this->load->view('ajax_response/ajax_template', $data);
    }

    public function get_district() {
        $provinceId = $_GET['provid'];
        $data['data_cate'] = 'district';
        $data['locations'] = $this->location_model->get_district($provinceId);
        $data['content'] = 'ajax_response/response_location';
        $data['display'] = "ស្រុក";
        $this->load->view('ajax_response/ajax_template', $data);
    }

    public function get_commune() {
        $districtId = $_GET['distid'];
        $data['data_cate'] = 'commune';
        $data['locations'] = $this->location_model->get_commune($districtId);
        $data['content'] = 'ajax_response/response_location';
        $data['display'] = "ឃុំ";
        $this->load->view('ajax_response/ajax_template', $data);
    }

    public function get_village() {
        $communeId = $_GET['commid'];
        $data['data_cate'] = 'district';
        $data['locations'] = $this->location_model->get_village($communeId);
        $data['content'] = 'ajax_response/response_location';
        $data['display'] = "ភូមិ";
        $this->load->view('ajax_response/ajax_template', $data);
    }

}